public ResponseDTO CrearRegistro([FromBody] CreditAccountDTO value) { var Response = new ResponseDTO(); Data.ControlCenter.Model.CreditAccount u = new Data.ControlCenter.Model.CreditAccount(); u = AutoMapper.Mapper.Map <CreditAccountDTO, Data.ControlCenter.Model.CreditAccount>(value); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogCreacion(u.Log); uR.SaveOrUpdate(u); if (u.EntityID > 0) { Response.Success = true; Response.Message = "Creado"; AccountController ApiCuenta = new AccountController(); var Reg = ApiCuenta.GetByAccountNum(value.AccountNum); Reg.PaidToDate += value.DocTotal; Reg.Log.UserUpdate = u.Log.UserCreation; ApiCuenta.UpdateRegistro(Reg); CustomerController ApiCustomer = new CustomerController(); var Cliente = ApiCustomer.GetByCardCode(Reg.CardCode); Cliente.Balance -= value.DocTotal; Cliente.Log.UserUpdate = u.Log.UserCreation; ApiCustomer.UpdateBalance(Cliente); } return(Response); }
public ResponseDTO UpdateRegistro([FromBody] Appointments_medicalDTO value) { var Response = new ResponseDTO(); Data.ControlCenter.Model.Appointments_medical u; u = uR.GetById(value.EntityID, false); //u = AutoMapper.Mapper.Map(value, u); u.Scheduledhourend = value.Scheduledhourend; u.Status = (Data.ControlCenter.Model.nStatus)Enum.Parse(typeof(Data.ControlCenter.Model.nStatus), value.Status.ToString()); u.Comments = value.Comments; u.Medicalservice = value.Medicalservice; u.Address = value.Address; u.Log.UserUpdate = value.Log.UserUpdate; FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogModificacion(u.Log); uR.SaveOrUpdate(u); uR.CommitChanges(); Response.Success = true; Response.Message = "Actualizado"; return(Response); }
public ResponseDTO UpdateRegistro([FromBody] CustomerDTO value) { var Response = new ResponseDTO(); if (value.EntityID == 0) { Response.Message = "EntityID es requerido"; } try { Data.ControlCenter.Model.Customer u; u = uR.GetById(value.EntityID, false); u.Address = value.Address; u.CustomerName = value.CustomerName; u.Tel = value.Tel; u.Log.UserUpdate = value.Log.UserUpdate; // u = AutoMapper.Mapper.Map(value, u); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogModificacion(u.Log); uR.SaveOrUpdate(u); uR.CommitChanges(); Response.Success = true; Response.Message = "Actualizado"; } catch (Exception ex) { Response.Message = ex.Message; } return(Response); }
public ResponseDTO CrearRegistro([FromBody] CustomerDTO value) { var Response = new ResponseDTO(); try { Data.ControlCenter.Model.Customer u = new Data.ControlCenter.Model.Customer(); u = AutoMapper.Mapper.Map <CustomerDTO, Data.ControlCenter.Model.Customer>(value); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogCreacion(u.Log); uR.SaveOrUpdate(u); if (u.EntityID > 0) { Response.Success = true; Response.Message = "Creado"; Response.InternalKey = u.EntityID; } else { Response.Message = "No Creado"; } } catch (Exception ex) { throw ex; } return(Response); }
public ResponseDTO CrearRegistro([FromBody] AccountDTO value) { var Response = new ResponseDTO(); if (String.IsNullOrEmpty(value.AccountName)) { Response.Message = "AccountName es requerido"; return(Response); } if (value.CardCode == 0) { Response.Message = "CardCode es requerido"; return(Response); } if (value.InitialBalance == 0 || value.InitialBalance < 0) { Response.Message = "InitialBalance es requerido"; return(Response); } value.AccountRef = "SALES-" + value.CardCode.ToString(); value.Status = "Abierto"; Data.ControlCenter.Model.Account u = new Data.ControlCenter.Model.Account(); u = AutoMapper.Mapper.Map <AccountDTO, Data.ControlCenter.Model.Account>(value); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogCreacion(u.Log); uR.SaveOrUpdate(u); if (u.EntityID > 0) { Response.Success = true; Response.Message = "Creado"; Response.InternalKey = u.EntityID; u = uR.GetById(u.EntityID, false); u.AccountRef = "SALES-" + value.CardCode + "-" + Response.InternalKey; uR.SaveOrUpdate(u); uR.CommitChanges(); CustomerController ApiCustomer = new CustomerController(); var Cliente = ApiCustomer.GetByCardCode(u.CardCode); Cliente.Balance += value.InitialBalance; Cliente.Log.UserUpdate = u.Log.UserCreation; ApiCustomer.UpdateBalance(Cliente); } return(Response); }
public ResponseDTO CrearRegistro([FromBody] AccountUserDTO value) { var Response = new ResponseDTO(); var IdPersonal = value.EntityID; value.EntityID = 0; Data.ControlCenter.Model.AccountUser u = new Data.ControlCenter.Model.AccountUser(); u = AutoMapper.Mapper.Map <AccountUserDTO, Data.ControlCenter.Model.AccountUser>(value); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogCreacion(u.Log); uR.SaveOrUpdate(u); if (u.EntityID > 0) { Response.Success = true; Response.Message = "Creado"; switch (value.IdProfile) { case 1: { API.PatientsController ApiUpdate = new PatientsController(); var oData = ApiUpdate.GetID(new PatientsDTO { EntityID = IdPersonal }); oData.IdAccountUser = u.EntityID; ApiUpdate.UpdateRegistro(oData); break; } case 2: { API.MedicController ApiUpdate = new MedicController(); var oData = ApiUpdate.GetID(new MedicDTO { EntityID = IdPersonal }); oData.IdAccountUser = u.EntityID; ApiUpdate.UpdateRegistro(oData); break; } case 3: { break; } } } return(Response); }
public ResponseDTO CrearRegistro([FromBody] MedicDTO value) { var Response = new ResponseDTO(); Data.ControlCenter.Model.Medic u = new Data.ControlCenter.Model.Medic(); u = AutoMapper.Mapper.Map <MedicDTO, Data.ControlCenter.Model.Medic>(value); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogCreacion(u.Log); uR.SaveOrUpdate(u); if (u.EntityID > 0) { Response.Success = true; Response.Message = "Creado"; } return(Response); }
public ResponseDTO UpdateRegistro([FromBody] MedicDTO value) { var Response = new ResponseDTO(); Data.ControlCenter.Model.Medic u; u = uR.GetById(value.EntityID, false); u = AutoMapper.Mapper.Map(value, u); FuncionLogActualizaciones L = new FuncionLogActualizaciones(); L.LogModificacion(u.Log); uR.SaveOrUpdate(u); uR.CommitChanges(); Response.Success = true; Response.Message = "Actualizado"; return(Response); }