public void EditCarrier(CarrierModel carrier)
        {
            var entity = _carrierMapper.MapToEntity(carrier);

            _uof.Carriers.Update(entity);
            _uof.Complete();
        }
Esempio n. 2
0
        public JsonResult GetJsonByFreightType(String FreightType)
        {
            IEnumerable <CarrierAirLine> CarrierAirLineList = null;
            List <CarrierModel>          Carrires           = new List <CarrierModel>();

            if (FreightModel.FreightTypes.AirFreight.ToString().Equals(FreightType))
            {
                CarrierAirLineList = carrierService.GetAllByType(CarrierType.AirLine.ToString());
            }
            else if (FreightModel.FreightTypes.OceanFreight.ToString().Equals(FreightType))
            {
                CarrierAirLineList = carrierService.GetAllByType(CarrierType.ShippingLine.ToString());
            }
            else
            {
                CarrierAirLineList = carrierService.GetQuery();
            }
            foreach (CarrierAirLine CarrierAirLine1 in CarrierAirLineList)
            {
                CarrierModel CarrierModel1 = new CarrierModel();
                CarrierModel1.Id                 = CarrierAirLine1.Id;
                CarrierModel1.Description        = CarrierAirLine1.Description;
                CarrierModel1.CarrierAirLineName = CarrierAirLine1.CarrierAirLineName;
                Carrires.Add(CarrierModel1);
            }
            return(this.Json(Carrires, JsonRequestBehavior.AllowGet));
        }
        public void AddCarrier(CarrierModel carrier)
        {
            var entity = _carrierMapper.MapToEntity(carrier);

            _uof.Carriers.Add(entity);
            _uof.Complete();
        }
Esempio n. 4
0
        public virtual ActionResult Edit(long id, CarrierModel model)
        {
            if (!ModelState.IsValid)
            {
                BindBag();

                return(View());
            }

            try
            {
                _carriers.Update(id, model.Name, model.Email, model.Phone, model.Contact, model.Address, model.Authentication.Login);

                _carriers.SetCities(id, model.Cities);

                if (!string.IsNullOrWhiteSpace(model.Authentication.NewPassword))
                {
                    var data = _carriers.Get(id);

                    _users.SetPassword(data.UserId, model.Authentication.NewPassword);
                }

                return(RedirectToAction(MVC.Carrier.Edit(id)));
            }
            catch (DublicateLoginException)
            {
                ModelState.AddModelError("Authentication.Login", Validation.LoginExists);

                BindBag();

                return(View());
            }
        }
Esempio n. 5
0
        public virtual ActionResult Create(CarrierModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Authentication.NewPassword))
            {
                ModelState.AddModelError("NewPassword", Validation.EmplyPassword);
            }

            if (!ModelState.IsValid)
            {
                BindBag();

                return(View());
            }

            try
            {
                var id = _carriers.Add(model.Name, model.Email, model.Phone, model.Contact, model.Address,
                                       model.Authentication.Login, model.Authentication.NewPassword, _identity.Language);

                _carriers.SetCities(id, model.Cities);

                return(RedirectToAction(MVC.Carrier.Edit(id)));
            }
            catch (DublicateLoginException)
            {
                ModelState.AddModelError("Authentication.Login", Validation.LoginExists);

                BindBag();

                return(View());
            }
        }
Esempio n. 6
0
 public ActionResult EditCarrierDetails(int id, CarrierModel obj)
 {
     try
     {
         _carrierService.ModifyCarrier(obj);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 7
0
 private void MapSelectedCarrier(PolicyModel policy, CarrierModel carrier)
 {
     if (carrier == null)
     {
         return;
     }
     policy.SelectedCarrier = new CarrierDdlModel()
     {
         Id   = carrier.Id,
         Name = carrier.Name
     };
 }
        public IActionResult Create()
        {
            repositoryTruckType.setResource("truck/");
            ViewData["truckTypes"] = repositoryTruckType.getAll();

            repositoryRoute.setResource("route/");
            //ViewData["routes"] = repositoryRoute.getAll();
            // Refactorizar este modelo con un ViewModel
            CarrierModel model = new CarrierModel
            {
                ids_Route = repositoryRoute.getAll().ToList()
            };

            return(View(model));
        }
Esempio n. 9
0
        public static CarrierModel GetCarrierData(string rfid)
        {
            string       _err    = string.Empty;
            string       sql     = "[PaintRecords].[dbo].[GetCarrierPaintedCounts]";
            CarrierModel carrier = new CarrierModel();

            try
            {
                using (SqlConnection conn = new SqlConnection(DECOSQL))
                {
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@CarrierRFID ", rfid);
                        cmd.Connection = conn;
                        conn.Open();

                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                carrier.CarrierNumber    = reader.GetInt32(reader.GetOrdinal("Carrier"));
                                carrier.StyleDescription = reader.GetString(reader.GetOrdinal("Style"));
                                carrier.ColorDescription = reader.GetString(reader.GetOrdinal("Color"));
                                carrier.BottomCount      = reader.GetInt32(reader.GetOrdinal("BottomCount"));
                                carrier.TopCount         = reader.GetInt32(reader.GetOrdinal("TopCount"));
                                carrier.TopLimit         = reader.GetInt32(reader.GetOrdinal("TopLimit"));
                                if (!reader.IsDBNull(reader.GetString(reader.GetOrdinal("RepairReason"))))
                                {
                                    carrier.RepairReason = reader.GetString(reader.GetOrdinal("RepairReason"));
                                }
                            }
                        }

                        reader.Close();
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                _err = ex.Message;
            }

            return(carrier);
        }
Esempio n. 10
0
 public ActionResult EditCarrier(CarrierModel model)
 {
     ViewData["CarrierTypes"] = CarrierTypes;
     if (ModelState.IsValid)
     {
         if (model.Id > 0)
         {
             carrierService.UpdateCarrier(model);
         }
         else
         {
             carrierService.InsertCarrier(model);
         }
         return(Json(1));
     }
     return(PartialView("_CarrieFormEdit", model));
 }
Esempio n. 11
0
        public static List <CarrierModel> GetCarriers()
        {
            List <CarrierModel> carriers = new List <CarrierModel>();
            int    count = 0;
            string sql   = "SELECT [ptrfid],[ptdatetime] FROM [ptMagnaGA].[dbo].[ptPaintReads] where [ptstation] = 'DoorSeven1' and ptdatetime >= dateadd(minute, -60, getdate()) order by ptdatetime desc";

            try
            {
                using (SqlConnection conn = new SqlConnection(DECOSQL))
                {
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.Connection = conn;
                        conn.Open();

                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                var          rfid    = reader.GetString(reader.GetOrdinal("ptrfid"));
                                CarrierModel carrier = new CarrierModel();
                                carrier = GetCarrierData(rfid);
                                if (carrier.CarrierNumber != 0)
                                {
                                    carrier.RFID        = rfid;
                                    carrier.TimeScanned = reader.GetDateTime(reader.GetOrdinal("ptdatetime"));
                                    carriers.Add(carrier);
                                    count++;
                                }
                            }
                        }

                        reader.Close();
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                string _err = ex.Message;
            }

            return(carriers);
        }
Esempio n. 12
0
        public virtual ViewResult Edit(long id)
        {
            BindBag();

            var data = _carriers.Get(id);

            var model = new CarrierModel
            {
                Authentication = new AuthenticationModel(data.Login),
                Email          = data.Email,
                Cities         = _carriers.GetCities(id),
                Name           = data.Name,
                Contact        = data.Contact,
                Phone          = data.Phone,
                Address        = data.Address
            };

            return(View(model));
        }
Esempio n. 13
0
        public bool AddCarrier(CarrierModel carrier)
        {
            var entity = new Carrier()
            {
                Name         = carrier.Name,
                AddressLine1 = carrier.AddressLine1,
                AddressLine2 = carrier.AddressLine2,
                City         = carrier.City,
                State        = carrier.State,
                ZipCode      = carrier.ZipCode,
                Email        = carrier.Email,
                Phone        = carrier.Phone,
                IsActive     = true,
                AddUser      = LoginUserDetails.GetWindowsLoginUserName(),
                AddDate      = DateUtil.GetCurrentDate()
            };

            return(_carrierRepository.Add(entity));
        }
Esempio n. 14
0
        public ActionResult AddCarrier(CarrierModel carrier)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = _carrierService.AddCarrier(carrier);

                    if (result)
                    {
                        ViewBag.Message = "Partner details added successfully";
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        private bool AddCarrier(CarrierModel carrierModel)
        {
            var editWindow = new EditCarrierWindow();
            var ctx        = (EditCarrierViewModel)editWindow.DataContext;

            ctx.Carrier = carrierModel;
            if (editWindow.ShowDialog() != true)
            {
                return(false);
            }

            var errs = GetModelErrors(ctx.Carrier);

            if (errs != string.Empty)
            {
                ShowError(errs, "Error! Saving cancelled. ");
                return(false);
            }

            _carrierService.AddCarrier(carrierModel);
            return(true);
        }
Esempio n. 16
0
        public bool ModifyCarrier(CarrierModel carrier)
        {
            var entity = new Carrier()
            {
                Id           = carrier.Id,
                IsActive     = (bool)carrier.IsActive,
                Name         = carrier.Name,
                AddressLine1 = carrier.AddressLine1,
                AddressLine2 = carrier.AddressLine2,
                City         = carrier.City,
                State        = carrier.State,
                ZipCode      = carrier.ZipCode,
                Email        = carrier.Email,
                AddDate      = carrier.AddDate,
                AddUser      = carrier.AddUser,
                Phone        = carrier.Phone,
                RevDate      = DateUtil.GetCurrentDate(),
                RevUser      = LoginUserDetails.GetWindowsLoginUserName()
            };

            return(_carrierRepository.Update(entity));
        }
        public IActionResult Create(CarrierModel carrier)
        {
            bool actionSuccessfully = ModelState.IsValid;

            if (actionSuccessfully)
            {
                repositoryCarrier.setResource("carrier/");
                CarrierModel carrierCreated = repositoryCarrier.create(carrier);

                TempData["newCarrier"] = serializeJSON(carrierCreated);

                TempData["registerSuccessfully"] = true;
                carrier = new CarrierModel
                {
                    ids_Route = repositoryRoute.getAll().ToList()
                };
                ModelState.Clear();
                //return RedirectToAction(nameof(Details));
            }
            // listar los datos necesarios para las relaciones de la clase Carrier
            ViewData["truckTypes"] = repositoryTruckType.getAll();
            return(View(carrier));
            //return RedirectToAction("DetalleChofer",carrier); // modificar
        }
        private bool EditCarrier(CarrierModel carrier)
        {
            var editWindow  = new EditCarrierWindow();
            var ctx         = (EditCarrierViewModel)editWindow.DataContext;
            var carrierCopy = new CarrierModel();

            CopyFields(carrier, carrierCopy);
            ctx.Carrier = carrierCopy;
            if (editWindow.ShowDialog() != true)
            {
                return(false);
            }
            var errs = GetModelErrors(carrierCopy);

            if (errs != string.Empty)
            {
                ShowError(errs, "Error! Saving cancelled. ");
                return(false);
            }

            CopyFields(carrierCopy, carrier);
            _carrierService.EditCarrier(carrier);
            return(true);
        }
Esempio n. 19
0
        public IList <CarrierModel> GetAllCarriers()
        {
            var carriers = new List <CarrierModel>();

            var carriersData = _carrierRepository.GetAll();

            if (carriersData == null)
            {
                return(carriers);
            }

            carriersData.ToList().ForEach(entity =>
            {
                var carrier = new CarrierModel()
                {
                    Id           = entity.Id,
                    IsActive     = (bool)entity.IsActive,
                    Name         = entity.Name,
                    AddressLine1 = entity.AddressLine1,
                    AddressLine2 = entity.AddressLine2,
                    City         = entity.City,
                    State        = entity.State,
                    ZipCode      = entity.ZipCode,
                    Email        = entity.Email,
                    AddDate      = entity.AddDate,
                    AddUser      = entity.AddUser,
                    Phone        = entity.Phone,
                    RevDate      = entity.RevDate,
                    RevUser      = entity.RevUser
                };

                carriers.Add(carrier);
            });

            return(carriers);
        }
Esempio n. 20
0
        public HttpResponseMessage GetMails(int start, int limit, string folder, string parFolder, string mailAction, string mailIds, string filter, int page)
        {
            IEnumerable <Carrier> listCarrier = new List <Carrier>();
            CarrierModel          model       = new CarrierModel();
            int mailAct = 0;

            start++;
            if (mailAction.ToString() != "NaN")
            {
                mailAct = int.Parse(mailAction);
            }
            string   message = null;
            MailUser acc     = WebMailClientManager.getAccount();

            if (string.IsNullOrEmpty(mailIds))
            {
                mailIds = string.Empty;
            }
            message = DoAction(folder, parFolder, mailAct, mailIds, message, acc);
            ResultList <MailHeader> m = new ResultList <MailHeader>(start, limit, new List <MailHeader>(), 0);

            // IEnumerable<string> items = null;
            if (acc != null && acc.IsManaged && !String.IsNullOrEmpty(filter))
            {
                DataContractJsonSerializer s  = new DataContractJsonSerializer(typeof(Filter));
                System.IO.MemoryStream     ms = new System.IO.MemoryStream();
                byte[] res = new byte[filter.Length];
                Encoding.UTF8.GetBytes(filter, 0, filter.Length, res, 0);
                ms.Write(res, 0, res.Length);
                ms.Seek(0, System.IO.SeekOrigin.Begin);
                Filter filtro = (Filter)s.ReadObject(ms);

                Dictionary <MailIndexedSearch, List <string> > sValues = new Dictionary <MailIndexedSearch, List <string> >();
                if (filtro.text.tipo != MailIndexedSearch.UNKNOWN &&
                    (filtro.text.values != null && filtro.text.values.Length > 0))
                {
                    sValues.Add(filtro.text.tipo, filtro.text.values.ToList());
                }
                if (filtro.status.tipo != MailIndexedSearch.UNKNOWN &&
                    (filtro.status.values != null && filtro.status.values.Length > 0))
                {
                    sValues.Add(filtro.status.tipo, filtro.status.values.Select(e => ((int)e).ToString()).ToList());
                }
                MailLocalService mailService       = new MailLocalService();
                ResultList <MailHeaderExtended> rl = mailService.GetMailsByParams(acc.EmailAddress, folder, parFolder, sValues, start, limit);

                m.Per    = rl.Per;
                m.List   = (rl.List == null) ? null : rl.List.Cast <MailHeader>().ToList() as ICollection <MailHeader>;
                m.Totale = rl.Totale;
            }
            else
            {
                MailServerFacade mailServerFacade = MailServerFacade.GetInstance(acc);
                m = mailServerFacade.MailHeader_ResultList_Fetch(folder, parFolder, start, limit);
            }

            if (m != null && m.List != null)
            {
                CultureInfo ci = CultureInfo.InvariantCulture;
                System.Runtime.Serialization.Json.DataContractJsonSerializer ser =
                    new DataContractJsonSerializer(typeof(Carrier));
                if (acc.IsManaged)
                {
                    listCarrier = m.List.Cast <MailHeaderExtended>().Select(h =>
                    {
                        string mStatus      = "";
                        string destinatario = "";
                        switch (parFolder)
                        {
                        case "I":
                            mStatus      = h.MailRating.ToString();
                            destinatario = h.From;
                            break;

                        case "O":
                        case "AO":
                            mStatus = ((int)h.MailStatus).ToString();
                            //per gestire il semaforo per gli invii da server non PEC
                            if (!acc.IsPec && h.MailStatus == MailStatus.SENT)
                            {
                                mStatus = ((int)MailStatus.AVVENUTA_CONSEGNA).ToString();
                            }
                            destinatario = h.To;
                            break;

                        default:
                            MailUser muser = WebMailClientManager.getAccount();
                            string idnome  = (from f in muser.Folders
                                              where f.Id.ToString() == folder
                                              select f.IdNome).First();
                            string tipo = (from f in muser.Folders
                                           where f.Id.ToString() == folder
                                           select f.TipoFolder).First();
                            switch (idnome)
                            {
                            case "1":
                            case "3":
                                mStatus      = h.MailRating.ToString();
                                destinatario = h.From;
                                break;

                            case "2":
                                mStatus = ((int)h.MailStatus).ToString();
                                //per gestire il semaforo per gli invii da server non PEC
                                if (!acc.IsPec && h.MailStatus == MailStatus.SENT)
                                {
                                    mStatus = ((int)MailStatus.AVVENUTA_CONSEGNA).ToString();
                                }
                                destinatario = h.To;
                                break;

                            default:
                                switch (tipo)
                                {
                                case "E":
                                    mStatus      = h.MailRating.ToString();
                                    destinatario = h.From;
                                    break;

                                case "D":
                                    mStatus = ((int)h.MailStatus).ToString();
                                    //per gestire il semaforo per gli invii da server non PEC
                                    if (!acc.IsPec && h.MailStatus == MailStatus.SENT)
                                    {
                                        mStatus = ((int)MailStatus.AVVENUTA_CONSEGNA).ToString();
                                    }
                                    destinatario = h.To;
                                    break;
                                }
                                break;
                            }
                            break;
                        }

                        ActiveUp.Net.Mail.Address add = ActiveUp.Net.Mail.Parser.ParseAddress(destinatario);
                        if (String.IsNullOrEmpty(add.Name))
                        {
                            destinatario = add.Email;
                        }
                        else
                        {
                            destinatario = System.Text.RegularExpressions.Regex.Replace(add.Name,
                                                                                        "Per conto di:?", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Trim();
                            if (destinatario.EndsWith("\""))
                            {
                                destinatario.Replace("\"", "");
                            }
                        }

                        Carrier c = new Carrier
                        {
                            id      = h.UniqueId,
                            from    = destinatario.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace("\"", "\\\""),
                            date    = h.Date.ToString("dd/MM/yyyy HH:mm:ss", ci),
                            subject = h.Subject.Replace("\"", "\\\""),
                            sStatus = mStatus,
                            mStatus = ((int)h.MailStatus).ToString(),
                            attach  = Convert.ToInt16(h.HasAttachments).ToString(),
                            utente  = ((h.MailStatus == MailStatus.SCARICATA) ? "" : h.Utente),
                            dimen   = h.Dimensione
                        };
                        return(c);
                        //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        //ser.WriteObject(ms, c);
                        //string jsonString = Encoding.UTF8.GetString(ms.ToArray());
                        //ms.Close();
                        //return jsonString;
                    });
                }
                else
                {
                    listCarrier = m.List.Select(h =>
                    {
                        Carrier c = new Carrier()
                        {
                            id      = h.UniqueId,
                            from    = h.From.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace("\"", "\\\""),
                            date    = h.Date.ToString("dd/MM/yyyy HH:mm:ss", ci),
                            subject = h.Subject.Replace("\"", "\\\""),
                            mStatus = ((int)MailStatus.UNKNOWN).ToString(),
                            sStatus = "",
                            attach  = ""
                        };
                        return(c);
                        //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        //ser.WriteObject(ms, c);
                        //string jsonString = Encoding.UTF8.GetString(ms.ToArray());
                        //ms.Close();
                        //return jsonString;
                    });
                }
            }
            else
            {
                model.Message = "Nessun ritrovamento";
                return(this.Request.CreateResponse <CarrierModel>(HttpStatusCode.OK, model));
                //message = "Nessun ritrovamento";
            }

            //StringBuilder sb = new StringBuilder();
            //sb.Append("{\"TotalCount\":\"" + m.Totale.ToString() + "\",");
            //sb.Append("\"Message\":\"" + message + "\"");
            //if (items != null)
            //{
            //    sb.Append(",\"Data\":[" + String.Join(",", items.ToArray()) + "]");
            //}
            //else
            //{
            //    sb.Append(",\"Data\": []");
            //}
            //sb.Append("}");
            model.TotalCount = m.Totale.ToString();
            model.data       = listCarrier.ToList();
            model.success    = "true";
            return(this.Request.CreateResponse <CarrierModel>(HttpStatusCode.OK, model));
            //context.Response.ContentType = "application/json";
            //context.Response.AppendHeader("Content-type", "text/json");
            //context.Response.Write(sb.ToString());
        }