public TbGeEmpresa ViewModelToDomainCrear(EmpresaViewModel model) { var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "uploads"); var domain = new TbGeEmpresa { Bd = model.Bd, CedJuridica = model.CedJuridica, Correo = model.Correo, Direccion = model.Direccion, Estado = true, FechaCreacion = DateTime.Now, FechaMod = DateTime.Now, Nombre = model.Nombre, Telefono1 = model.Telefono1, Telefono2 = model.Telefono2, IdGrupoEmpresarial = model.Id_GE, TienePuntoVentaDefecto = model.TienePuntoVentaDefecto, IdPuntoVenta = model.IdPuntoVenta }; if (model.Foto != null) { domain.Foto = FotosService.SubirFotoEmpresa(model.Foto, savePath); } else { domain.Foto = ""; } return(domain); }
public IActionResult CrearEmpresa(EmpresaViewModel model) { var result = new TbGeEmpresa(); try { var existeEmpresaN = service.GetEmpresaByNombre(model.Nombre); if (existeEmpresaN != null) { return(Json(new { success = _sharedLocalizer["yaExisteEmpresa"].ToString() })); } var existeEmpresaC = service.GetByCedula(model.CedJuridica); if (existeEmpresaN != null) { return(Json(new { success = _sharedLocalizer["yaExisteEmpresa"].ToString() })); } model.Id_GE = (int)service.GetGE().Id; result = geMap.Create(model); if (result != null) { var res = service.CrearBD(model.Bd); if (res) { service.AgregarUsuarios((int)result.Id); // return Json(new { success = true }); return(Json(new { success = true })); } else { ///eliminar datos si la bd no se crea //var em = service.GetEmpresaById((int)result.Id); var deleted = service.EliminarEmpresa(result); return(Json(new { success = _sharedLocalizer["errorGeneral"].ToString() })); } } else { return(Json(new { success = _sharedLocalizer["errorGeneral"].ToString() })); } } catch (Exception ex) { AltivaLog.Log.Insertar(ex.ToString(), "Error"); var deleted = service.EliminarEmpresa(result); return(BadRequest(new { success = _sharedLocalizer["errorGeneral"].ToString() })); } }
public EmpresaViewModel DomainToViewModel(TbGeEmpresa domain) { var model = new EmpresaViewModel { Bd = domain.Bd, CedJuridica = domain.CedJuridica, Correo = domain.Correo, Direccion = domain.Direccion, Estado = domain.Estado, Foto = null, Id_GE = (int)domain.IdGrupoEmpresarial, Nombre = domain.Nombre, Telefono1 = domain.Telefono1, Telefono2 = domain.Telefono2 }; return(model); }
public TbGeEmpresa ViewModelToDomainCrear(EmpresaViewModel model) { var domain = new TbGeEmpresa { Bd = model.Bd, CedJuridica = model.CedJuridica, Correo = model.Correo, Direccion = model.Direccion, Estado = model.Estado, FechaCreacion = DateTime.Now, FechaMod = DateTime.Now, Nombre = model.Nombre, Telefono1 = model.Telefono1, Telefono2 = model.Telefono2, IdGrupoEmpresarial = model.Id_GE, Foto = FotosService.SubirFotoEmpresa(model.Foto) }; return(domain); }
public bool EliminarEmpresa(TbGeEmpresa domain) { return(repository.EliminarEmpresa(domain)); }
public TbGeEmpresa Update(TbGeEmpresa domain) { return(repository.Update(domain)); }
public TbGeEmpresa Save(TbGeEmpresa domain) { return(repository.Save(domain)); }