Example #1
0
        public override bool UpdateData(int userId, int id, ref object dtoItem, out Notification notification)
        {
            DTO.CostInvoice2CreditorMngDto costInvoice2CreditorMngDto = ((JObject)dtoItem).ToObject <DTO.CostInvoice2CreditorMngDto>();
            notification = new Notification()
            {
                Type = NotificationType.Success
            };

            try
            {
                using (var context = CreatContext())
                {
                    CostInvoice2Creditor costInvoice2Creditor = new CostInvoice2Creditor();

                    if (id == 0)
                    {
                        context.CostInvoice2Creditor.Add(costInvoice2Creditor);
                    }
                    if (id > 0)
                    {
                        costInvoice2Creditor = context.CostInvoice2Creditor.FirstOrDefault(o => o.CostInvoice2CreditorID == id);
                        if (costInvoice2Creditor == null)
                        {
                            notification = new Notification()
                            {
                                Type = NotificationType.Error, Message = "Can't Find Data"
                            };
                            return(false);
                        }
                    }

                    this.converter.BTO2DB_CostInvoice2CreditorMng(costInvoice2CreditorMngDto, ref costInvoice2Creditor);
                    context.SaveChanges();

                    dtoItem = this.GetData(costInvoice2Creditor.CostInvoice2CreditorID, out notification);
                }
                return(true);
            }               catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type = NotificationType.Error, Message = ex.Message
                };
                return(false);
            }
        }
Example #2
0
 public void BTO2DB_CostInvoice2CreditorMng(DTO.CostInvoice2CreditorMngDto dto, ref CostInvoice2Creditor db)
 {
     AutoMapper.Mapper.Map <DTO.CostInvoice2CreditorMngDto, CostInvoice2Creditor>(dto, db);
 }