示例#1
0
 //TODO: User Auto Mapper
 public ClientFile(ClientFileViewModel clientFileView)
 {
     FileNumber = clientFileView.FileNumber;
     ClientName = clientFileView.ClientName;
     ClientContactPerson = clientFileView.ClientContactPerson;
     AssociateReponsible = clientFileView.AssociateReponsible;
     CaSign = clientFileView.CaSign;
     DscExpiryDate = clientFileView.DscExpiryDate;
     FileStatus = clientFileView.FileStatus;
     FileStatusModifications.Add(clientFileView.InitialFileStatus);
 }
        public ActionResult Create(ClientFileViewModel clientFileView)
        {
            clientFileView.UserName = User.Identity.GetUserName();
            clientFileView.InitialFileStatus = new FileStatusModification
            {
                OldStatus = "New",
                NewStatus = "New",
                Description = "Started",
                ModifiedBy = clientFileView.UserName
            };

            var clientFile = new ClientFile(clientFileView);

            _assistantContext.ClientFiles.InsertOneAsync(clientFile).Wait();

            return RedirectToAction("Index");
        }
        public ActionResult Edit(ClientFileViewModel clientFileView)
        {
            var filter = Builders<ClientFile>.Filter.Eq("_id", new ObjectId(clientFileView.Id));
            var clientFile = _assistantContext.ClientFiles.Find(filter).FirstOrDefaultAsync().Result;
            clientFileView.UserName = User.Identity.GetUserName();

            var filestatus = new FileStatusModification
            {
                OldStatus = clientFile.FileStatus,
                NewStatus = clientFileView.FileStatus,
                Description = "Review",
                ModifiedBy = clientFileView.UserName
            };
            clientFile.AddFileStatus(filestatus);

            var update = Builders<ClientFile>.Update
                .Set("FileStatusModifications", clientFile.FileStatusModifications)
                .Set("FileStatus", filestatus.NewStatus);
            var result = _assistantContext.ClientFiles.UpdateOneAsync(filter, update).Result;

            return RedirectToAction("Index");
        }
 public ActionResult Edit(string id)
 {
     var clientFile = GetClientFile(id);
     var clientFileView = new ClientFileViewModel(clientFile);
     return View(clientFileView);
 }