asp.net mvc 4 - Error: Only primitive types or enumeration types are supported in this context -


[httppost]     public actionresult dep_save_attachments(int in_queue_id, httppostedfilebase httpfile, string authorized_by, string authorized_to, string confirmed_by, string approved_by)     {         if (httpfile != null)         {              var folder = server.mappath("~/attachments/laptops/" + in_queue_id + "/");             var prev_fa = db.file_attachments.where(x => x.inventory_table_id == in_queue_id).where(x => x.is_active == true).tolist();             var prev_hfa = db.hw_authorization_forms.where(x => x.file_attachments_id == prev_fa.firstordefault().file_attachments_id).where(x => x.is_active == true).tolist();              if (!directory.exists(folder))             {                 directory.createdirectory(folder);             }              if (prev_fa.count != 0)             {                 foreach (var pf in prev_fa)                 {                     pf.is_active = false;                      db.entry(pf).state = entitystate.modified;                     db.savechanges(); ;                 }             }              if (prev_hfa.count != 0)             {                 foreach (var hpf in prev_hfa)                 {                     hpf.is_active = false;                      db.entry(hpf).state = entitystate.modified;                     db.savechanges(); ;                 }             }                try             {                 string path = system.web.httpcontext.current.server.mappath("~/attachments/laptops/" + in_queue_id + "/") + system.io.path.getfilename(httpfile.filename);                 httpfile.saveas(path);                  file_attachments fa = new file_attachments();                  fa.file_attachments_id = 1;                 fa.inventory_table_name = "laptops_transactions";                 fa.inventory_table_id = in_queue_id;                 fa.file_name = system.io.path.getfilename(httpfile.filename);                 fa.file_path = "http://" + request.url.host + ":" + request.url.port + "/attachments/laptops/" + httpfile.filename;                 fa.created_by = @user.identity.name.remove(0, 9).tolower();                 fa.created_date = system.datetime.now;                 fa.is_active = true;                  db.file_attachments.add(fa);                 db.savechanges();                  laptops_transactions laptops_trans = db.laptops_transactions.find(in_queue_id);                 laptops_trans.lp_trans_type = "deployed";                 laptops_trans.lp_date_returned = system.datetime.now;                  db.entry(laptops_trans).state = entitystate.modified;                 db.savechanges();                  hw_authorization_forms hwf = new hw_authorization_forms();                 hwf.hw_authorization_forms_id = 1;                 hwf.file_attachments_id = fa.file_attachments_id;                 hwf.hw_authorized_by = authorized_by;                 hwf.hw_authorized_to = authorized_to;                 hwf.hw_confirmed_by = confirmed_by;                 hwf.hw_approved_by = approved_by;                 hwf.hw_approved_date = fa.created_date;                 hwf.created_by = fa.created_by;                 hwf.created_date = fa.created_date;                 hwf.hw_authorized_date = fa.created_date;                 hwf.hw_confirmed_date = fa.created_date;                 hwf.is_active = true;                  db.hw_authorization_forms.add(hwf);                 db.savechanges();              }             catch             {              }         }         else         {              return content("<script language='javascript' type='text/javascript'>alert('please attach deployment authorization form! kindly go previous page');</script>");         }       return redirecttoaction("index");      } 

the error on line:

var prev_hfa = db.hw_authorization_forms.where(x => x.file_attachments_id == prev_fa.firstordefault().file_attachments_id).where(x => x.is_active == true).tolist(); 

this code in controller, working have error. don't have idea why have kind of error before works perfectly.

please me this. need advice. in advance.

the error because of datatype issue guess, need confirm doing correct datatype, file_attachments_id of database , comparing value must same.

also, is_active must of datatype boolean. correcting may solve error.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -