Esempio n. 1
0
 public bool Reset(int id, ref DTO.POL dtoItem, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
Esempio n. 2
0
 public void DTO2BD_POL(DTO.POL dtoItem, ref POL dbItem)
 {
     AutoMapper.Mapper.Map <DTO.POL, POL>(dtoItem, dbItem);
 }
Esempio n. 3
0
        public bool UpdateData(int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.POL dtoPOL = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.POL>();
            int     number;
            string  indexName;

            try
            {
                using (POLMngEntities context = CreateContext())
                {
                    POL dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new POL();
                        context.POL.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.POL.FirstOrDefault(o => o.PoLID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "Port of Loading  not found!";
                        return(false);
                    }
                    else
                    {
                        converter.DTO2BD_POL(dtoPOL, ref dbItem);
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.PoLID, out notification).Data;

                        return(true);
                    }
                }
            }
            catch (System.Data.DataException dEx)
            {
                notification.Type = Library.DTO.NotificationType.Error;
                Library.ErrorHelper.DataExceptionParser(dEx, out number, out indexName);
                if (number == 2601 && !string.IsNullOrEmpty(indexName))
                {
                    if (indexName == "POLlUDUnique")
                    {
                        notification.Message = "This port of loading already exists";
                    }
                }
                else
                {
                    notification.Message = dEx.Message;
                }

                return(false);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                return(false);
            }
        }