public ServiceResult Update(UnitOfMeasure s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid UnitsOfMeasure sent to server."));
            }

            UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);



            var dbS = (UnitOfMeasure)UnitsOfMeasureManager.GetBy(s.UUID);

            if (dbS == null)
            {
                return(ServiceResponse.Error("UnitsOfMeasure was not found."));
            }

            if (dbS.DateCreated == DateTime.MinValue)
            {
                dbS.DateCreated = DateTime.UtcNow;
            }
            dbS.Deleted   = s.Deleted;
            dbS.Name      = s.Name;
            dbS.Status    = s.Status;
            dbS.SortOrder = s.SortOrder;
            dbS.Category  = s.Category;
            dbS.ShortName = s.ShortName;
            return(UnitsOfMeasureManager.Update(dbS));
        }
Пример #2
0
        public ServiceResult Update(UnitOfMeasure s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid UnitsOfMeasure sent to server."));
            }

            UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            var res = UnitsOfMeasureManager.Get(s.UUID);

            if (res.Code != 200)
            {
                return(res);
            }

            var dbS = (UnitOfMeasure)res.Result;

            if (dbS.DateCreated == DateTime.MinValue)
            {
                dbS.DateCreated = DateTime.UtcNow;
            }
            dbS.Deleted   = s.Deleted;
            dbS.Name      = s.Name;
            dbS.Status    = s.Status;
            dbS.SortOrder = s.SortOrder;
            dbS.Category  = s.Category;
            dbS.ShortName = s.ShortName;
            return(UnitsOfMeasureManager.Update(dbS));
        }