Beispiel #1
0
 public string Add(Package package)
 {
     try
     {
         if (package != null)
         {
             if (!IsDuplicate(string.Empty, package.PackageName))
             {
                 package.PackageID = Guid.NewGuid().ToString();
                 package.UpdateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 package.UpdateDate = DateTime.Now;
                 package.CreateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 package.CreateDate = DateTime.Now;
                 db.Packages.Add(package);
                 db.SaveChanges();
                 return "Success";
             }
             else
             {
                 return "This package name already in used.";
             }
         }
     }
     catch(Exception ex)
     {
         LogFile.writeLogFile(DateTime.Now, "PackageController", ex.ToString());
     }
     return "Add user failed.";
 }
Beispiel #2
0
 public string Update(Package package)
 {
     try
     {
         if (package != null)
         {
             if (!IsDuplicate(package.PackageID, package.PackageName))
             {
                 var pack = db.Packages.Find(package.PackageID);
                 pack.PackageName = package.PackageName;
                 pack.PackageStatus = package.PackageStatus;
                 pack.UpdateDate = DateTime.Now;
                 pack.UpdateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 db.Entry(pack).State = EntityState.Modified;
                 db.SaveChanges();
                 return "Success";
             }
             else
             {
                 return "This package name already in used.";
             }
         }
     }
     catch (Exception ex) { LogFile.writeLogFile(DateTime.Now, "PackageController", ex.ToString()); }
     return "Update failed";
 }