Ejemplo n.º 1
0
        //public void UpdateStation(Expression<Func<TBL_STATION, bool>> where, Expression<Func<TBL_STATION, TBL_STATION>> updateValues)
        //{
        //    stationRepository.UpdateBulk(where, updateValues);
        //}

        public void DeleteStation(int stationId, string userId)
        {
            TBL_STATION comp = stationRepository.GetById(stationId);

            comp.UPDATE_USER = userId;
            comp.IS_DELETED  = true;
            stationRepository.Update(comp);
        }
Ejemplo n.º 2
0
        //public Category GetCategory(int id)
        //{
        //    var category = categorysRepository.GetById(id);
        //    return category;
        //}

        //public Category GetCategory(string name)
        //{
        //    var category = categorysRepository.GetCategoryByName(name);
        //    return category;
        //}

        public void CreateStation(TBL_STATION station)
        {
            stationRepository.Add(station);
        }
Ejemplo n.º 3
0
 public void UpdateStation(TBL_STATION station)
 {
     stationRepository.Update(station);
 }
Ejemplo n.º 4
0
 public bool IsStationExist(TBL_STATION station)
 {
     return(stationRepository.Get(x => x.IS_DELETED == false && x.ID != station.ID && station.COMPANY_ID == x.COMPANY_ID && x.NAME.ToUpper() == station.NAME.ToUpper()) == null ? false : true);
 }
Ejemplo n.º 5
0
        public ActionResult UpdateStation(StationGridModel station)
        {
            int companyId = !string.IsNullOrEmpty(Request.Params["companyId"]) ? int.Parse(Request.Params["companyId"]) : 0;

            if (ModelState.IsValid)
            {
                try
                {
                    TBL_STATION stat = Mapper.Map <StationGridModel, TBL_STATION>(station);
                    stat.COMPANY_ID = companyId;
                    if (!stationService.IsStationExist(stat))
                    {
                        stat.UPDATE_USER = User.Identity.GetUserId();

                        //SaveStationUsers(station.ID, station.USERS);

                        //if (station.PHOTO != null && station.PHOTO.Length > 0)
                        //{
                        //    string retVal = SaveStationPic(station.PHOTO, station.ID);
                        //    if (retVal.Length > 0)
                        //    {
                        //        ViewData["EditError"] = "Could not save picture. " + retVal;
                        //        ViewData["EditableProduct"] = station;
                        //    }
                        //    else
                        //    {
                        //        stat.PHOTO_PATH = stat.ID.ToString() + ".png";
                        //    }
                        //}
                        //else
                        //{
                        //    string retVal = DeleteStationPic(stat.ID);
                        //    if (retVal.Length > 0)
                        //    {
                        //        ViewData["EditError"] = "Could not delete picture. " + retVal;
                        //        ViewData["EditableProduct"] = station;
                        //    }
                        //    else
                        //    {
                        //        stat.PHOTO_PATH = "noimage.png";
                        //    }
                        //}
                        stationService.UpdateStation(stat);
                        stationService.SaveStation();
                        UpdateTargetStation(station, companyId);
                    }
                    else
                    {
                        ViewData["EditError"]       = "Name is already taken";
                        ViewData["EditableProduct"] = station;
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"]       = companyId == 0 ? "Please select a company." : "Please, correct all errors.";
                ViewData["EditableProduct"] = station;
            }

            return(PartialView("GridStationPartial", GetStationByCompanyId(companyId)));
        }
Ejemplo n.º 6
0
        public ActionResult SaveStation(StationGridModel station)
        {
            int companyId = !string.IsNullOrEmpty(Request.Params["companyId"]) ? int.Parse(Request.Params["companyId"]) : 0;
            int stationId = !string.IsNullOrEmpty(Request.Params["stationId"]) ? int.Parse(Request.Params["stationId"]) : 0;

            if (ModelState.IsValid && companyId > 0)
            {
                TBL_STATION stat = Mapper.Map <StationGridModel, TBL_STATION>(station);
                try
                {
                    stat.COMPANY_ID = companyId;

                    if (!stationService.IsStationExist(stat))
                    {
                        stat.CREATED_DATE = DateTime.Now;
                        stat.UPDATE_USER  = User.Identity.GetUserId();
                        stationService.CreateStation(stat);
                        stationService.SaveStation();
                        //SaveStationUsers(stat.ID,station.USERS);
                        string photoFileName = string.Empty;
                        if (station.PHOTO != null && station.PHOTO.Length > 0)
                        {
                            string retVal = SaveStationPic(station.PHOTO, stat.ID);

                            if (retVal.Length > 0)
                            {
                                ViewData["EditError"]       = "Could not save picture. " + retVal;
                                ViewData["EditableProduct"] = station;
                                photoFileName = "noimage.png";
                            }
                            else
                            {
                                photoFileName = stat.ID.ToString() + ".png";
                            }
                        }
                        else
                        {
                            photoFileName = "noimage.png";
                        }
                        stationService.UpdateStation(stat);
                        stationService.SaveStation();
                        stationId = stat.ID;

                        SaveTargetStation(station, stationId);
                    }
                    else
                    {
                        ViewData["EditableProduct"] = station;
                        ViewData["EditError"]       = "Name is already taken";
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"]       = "Please, correct all errors.";
                ViewData["EditableProduct"] = station;
            }
            return(PartialView("GridStationPartial", GetStationByCompanyId(companyId)));
        }