public PartialViewResult _adressesView(int __addressId, string __operation) { if (!String.IsNullOrEmpty(__operation)) { Advertiser_address _obj = _context.Advertisers_adresses.FirstOrDefault(x => x.Id == __addressId); IDictionary <string, string> _formHeaderAux = new Dictionary <string, string>(); _formHeaderAux.Add("St", _obj.St.ToString()); _formHeaderAux.Add("Operation", __operation); _formHeaderAux.Add("Id", _obj.Id.ToString()); _formHeaderAux.Add("Name", "Endereço"); _formHeaderAux.Add("DivId", "adressesView"); _formHeaderAux.Add("FormIdIcon", "stIconInTitle_address"); _formHeaderAux.Add("idInHeader", "idInHeader_address"); // id in header _formHeaderAux.Add("saveFormButtonId", "saveFormButton_address"); // id do botão save form _formHeaderAux.Add("thisScreenIs", "aux"); // parâmetro que determina se essa é a tala principal ou auxiliar _formHeaderAux.Add("divIdToshowHideDeleteButtonOnClick", "deleteRegisterConfirm_addressView"); // id da div escondida para deletar efetivamente o registro _formHeaderAux.Add("operationInHeader", "operationInHeader_address"); // operation in header _formHeaderAux.Add("addButton_aux", "advAddressMaintenance(0, 'a'," + _obj.AdvertiserId.ToString() + ")"); _formHeaderAux.Add("deleteButtonOnClick", "sendAddressToDeleteInForm('" + _formHeaderAux["DivId"] + "', '#" + _formHeaderAux["idInHeader"] + "')"); // função e parâmetro usado no "onclick()" do botão de exclusão de registros _formHeaderAux.Add("FormTitle", (__operation == "v" ? "visualizar" : __operation == "d" ? "deletar" : "") + " registro" ); ViewBag.FormHeaderAux = _formHeaderAux; ViewBag.Operation = __operation; return(PartialView(_obj)); } return(null); }
public Advertiser_address FillAllFields(Advertiser_address __obj) { if (__obj.CityId > 0) { __obj.CityName = _context.Cities.Find(__obj.CityId).Name; } return(__obj); }
public Advertiser_address Fix(Advertiser_address __obj) { __obj.AddUserId = 1; __obj.UpdateUserId = 1; __obj.UpdateDate = System.DateTime.Now; __obj.AddDate = __obj.Id > 0 ? __obj.AddDate : System.DateTime.Now; return(__obj); }
public JsonResult _jsonAdressesMaintenanceFormSubmit(FormCollection dados, Advertiser_address __obj) { //int _addressId = Convert.ToInt16(dados["inputAddressId"].ToString()); //int _advertiserId = Convert.ToInt16(dados["inputAdvertiserId"].ToString()); //var _st = Convert.ToString(dados["St"]); __obj = _advertisers_adressesApp.Save(__obj); return(Json(__obj, JsonRequestBehavior.AllowGet)); }
public Advertiser_address Add(Advertiser_address __obj) { using (var _context = new Context()) { _context.Advertisers_adresses.Add(__obj); _context.SaveChanges(); } return(__obj); }
public void Delete(int __id) { using (var _context = new Context()) { Advertiser_address _objToDelete = _context.Advertisers_adresses.Find(__id); if (_objToDelete != null) { _context.Advertisers_adresses.Remove(_objToDelete); _context.SaveChanges(); } } }
public Advertiser_address Save(Advertiser_address __obj) { Fix(__obj); if (__obj.Id == 0) // se não tem id é pq é um registro novo { __obj = Add(__obj); } else { __obj = Update(__obj); } return(__obj); }
public Advertiser_address Update(Advertiser_address __objUpdate) { using (var _context = new Context()) { //fonte: http://stackoverflow.com/questions/15336248/entity-framework-5-updating-a-record Advertiser_address _objOriginal = _context.Advertisers_adresses.Find(__objUpdate.Id); if (_objOriginal != null) { _context.Entry(_objOriginal).CurrentValues.SetValues(__objUpdate); _context.SaveChanges(); } } return(__objUpdate); }
public JsonResult _jsonAdressesFormFill(int __addressId = 0, string __operation = "a") { if (!String.IsNullOrEmpty(__operation)) { if (__operation == "a" || __operation == "e" || __operation == "d" || __operation == "v") { Advertiser_address _obj = new Advertiser_address(); if (__operation != "a") { if (__addressId > 0) { _obj = _advertisers_adressesApp.SearchById(__addressId, "full"); //_context.Advertisers_adresses.FirstOrDefault(x => x.Id == __addressId); } } ViewBag.AddressId = _obj.Id; return(Json(_obj, JsonRequestBehavior.AllowGet)); } } return(null); }
public PartialViewResult _adressesMaintenanceForm(int __addressId, string __operation, int __advertiserId) { if (!String.IsNullOrEmpty(__operation)) { if (__operation == "a" || __operation == "e" || __operation == "d" || __operation == "v") { Advertiser_address _obj = new Advertiser_address(); _obj.AdvertiserId = __advertiserId; ViewBag.AdvertiserId = __advertiserId; if (__operation != "a") { if (__addressId > 0) { var _obj_temp = _context.Advertisers_adresses.FirstOrDefault(x => x.Id == __addressId); if (_obj_temp != null) { _obj = _obj_temp; } } } IDictionary <string, string> _formHeaderAux = new Dictionary <string, string>(); _formHeaderAux.Add("St", _obj.St.ToString()); _formHeaderAux.Add("Operation", __operation); _formHeaderAux.Add("Id", _obj.Id.ToString()); _formHeaderAux.Add("Name", "Endereço"); //-apagar _formHeaderAux.Add("FormId", "addressMaintenanceForm"); _formHeaderAux.Add("DivId", "adressesMaintenanceForm"); //-apagar _formHeaderAux.Add("FormIdIcon", "stIconInTitle_address"); //-apagar _formHeaderAux.Add("thisScreenIs", "aux"); // parâmetro que determina se essa é a tala principal ou auxiliar _formHeaderAux.Add("idInHeader", "idInHeader_address"); // id in header _formHeaderAux.Add("saveFormButtonId", "saveFormButton_address"); // id do botão save form _formHeaderAux.Add("resetFormButtonId", "resetFormButton_address"); // id do botão reset form _formHeaderAux.Add("resetFormButtonFunction", "resetForm_address()"); // função para reset form e desabilitar o botão save _formHeaderAux.Add("operationInHeader", "operationInHeader_address"); // operation in header _formHeaderAux.Add("divIdToshowHideDeleteButtonOnClick", "deleteRegisterConfirm_address"); // id da div escondida para deletar efetivamente o registro _formHeaderAux.Add("addButton_aux", "advAddressMaintenance(0, 'a'," + __advertiserId.ToString() + ")"); _formHeaderAux.Add("deleteButtonOnClick", "sendAddressToDeleteInForm('" + _formHeaderAux["DivId"] + "', '#" + _formHeaderAux["idInHeader"] + "')"); // função e parâmetro usado no "onclick()" do botão de exclusão de registros _formHeaderAux.Add("FormTitle", (__operation == "a" ? "incluir" : __operation == "e" ? "editar" : __operation == "v" ? "visualizar" : __operation == "d" ? "deletar" : "") + " registro" ); ViewBag.FormHeaderAux = _formHeaderAux; UfsApp _ufsApp = new UfsApp(); CitiesApp _citiesApp = new CitiesApp(); ViewBag.Ddl_States = new SelectList(_ufsApp.ListAll(), "UF", "Name", _obj.Uf); ViewBag.Ddl_Cities = new SelectList(_citiesApp.ListAll(), "Id", "Name", _obj.CityId); //ViewBag.AddressId = _obj.Id; ViewBag.Operation = __operation; return(PartialView(_obj)); } } return(null); }