Exemplo n.º 1
0
        public ValidationMsg Update(SysLocation objSysLocation, int userid)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                var location = _context.Sys_Location.FirstOrDefault(s => s.LocationID == objSysLocation.LocationID);
                if (location != null)
                {
                    location.LocationName    = objSysLocation.LocationName;
                    location.LocationAddress = objSysLocation.LocationAddress;
                    location.ContactPerson   = objSysLocation.ContactPerson;
                    location.ContactNumber   = objSysLocation.ContactNumber;
                    location.IsActive        = objSysLocation.IsActive == "Active";
                    location.ModifiedOn      = DateTime.Now;
                    location.ModifiedBy      = userid;
                }

                _context.SaveChanges();

                _vmMsg.Type = Enums.MessageType.Update;
                _vmMsg.Msg  = "Updated Successfully.";
            }
            catch (Exception ex)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to Update.";
            }
            return(_vmMsg);
        }
Exemplo n.º 2
0
        public ValidationMsg Save(SysLocation objSysLocation, int userid)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                var tblSysLocation = new Sys_Location
                {
                    LocationID      = objSysLocation.LocationID,
                    LocationName    = objSysLocation.LocationName,
                    LocationAddress = objSysLocation.LocationAddress,
                    ContactPerson   = objSysLocation.ContactPerson,
                    ContactNumber   = objSysLocation.ContactNumber,
                    IsActive        = objSysLocation.IsActive == "Active",
                    IsDelete        = false,
                    SetOn           = DateTime.Now,
                    SetBy           = userid,
                    IPAddress       = string.Empty
                };

                _context.Sys_Location.Add(tblSysLocation);
                _context.SaveChanges();
                LocationId = tblSysLocation.LocationID;

                _vmMsg.Type = Enums.MessageType.Success;
                _vmMsg.Msg  = "Saved Successfully.";
            }
            catch (Exception ex)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to Save.";
            }

            return(_vmMsg);
        }
Exemplo n.º 3
0
 public void Test()
 {
     var sys = new SysLocation();
     Assert.Throws<ArgumentNullException>(() => sys.Data = null);
     Assert.Throws<ArgumentException>(() => sys.Data = new TimeTicks(0));
     sys.Data = OctetString.Empty;
     Assert.AreEqual(OctetString.Empty, sys.Data);
 }
Exemplo n.º 4
0
        public void Test()
        {
            var sys = new SysLocation();

            Assert.Throws <ArgumentNullException>(() => sys.Data = null);
            Assert.Throws <ArgumentException>(() => sys.Data     = new TimeTicks(0));
            sys.Data = OctetString.Empty;
            Assert.Equal(OctetString.Empty, sys.Data);
        }
Exemplo n.º 5
0
 public ActionResult Location(SysLocation model)
 {
     if (model != null && model.LocationID != 0)
     {
         _vmMsg = _dalSysLocation.Update(model, Convert.ToInt32(Session["UserID"]));
     }
     else
     {
         _vmMsg = _dalSysLocation.Save(model, Convert.ToInt32(Session["UserID"]));
     }
     return(Json(new { LocationID = _dalSysLocation.GetLocationId(), msg = _vmMsg }));
 }
Exemplo n.º 6
0
        public void Insert(string LocationName,string LocationIntro,string LocationContent,string LocationAddress,string LocationMan,int? CreatedBy,DateTime? CreatedOn,int? ModifiedBy,DateTime? ModifiedOn)
        {
            SysLocation item = new SysLocation();

            item.LocationName = LocationName;

            item.LocationIntro = LocationIntro;

            item.LocationContent = LocationContent;

            item.LocationAddress = LocationAddress;

            item.LocationMan = LocationMan;

            item.CreatedBy = CreatedBy;

            item.CreatedOn = CreatedOn;

            item.ModifiedBy = ModifiedBy;

            item.ModifiedOn = ModifiedOn;

            item.Save(UserName);
        }
Exemplo n.º 7
0
        public void Update(int Id,string LocationName,string LocationIntro,string LocationContent,string LocationAddress,string LocationMan,int? CreatedBy,DateTime? CreatedOn,int? ModifiedBy,DateTime? ModifiedOn)
        {
            SysLocation item = new SysLocation();
            item.MarkOld();
            item.IsLoaded = true;

            item.Id = Id;

            item.LocationName = LocationName;

            item.LocationIntro = LocationIntro;

            item.LocationContent = LocationContent;

            item.LocationAddress = LocationAddress;

            item.LocationMan = LocationMan;

            item.CreatedBy = CreatedBy;

            item.CreatedOn = CreatedOn;

            item.ModifiedBy = ModifiedBy;

            item.ModifiedOn = ModifiedOn;

            item.Save(UserName);
        }